home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / P Examples / hello.p < prev    next >
Encoding:
Text File  |  1994-08-28  |  1.4 KB  |  60 lines  |  [TEXT/PJMM]

  1. unit aCommand;
  2.  
  3. {  ================================================== }
  4.  
  5. { hello . p - an examle of a simple nShell (tm) command. }
  6.  
  7. { Copyright ( c ) 1994 Newport Software Development }
  8.  
  9. { You may distribute unmodified copies of this file for noncommercial }
  10. { purposes . You may use this file as a reference when writing your }
  11. { own nShell ( tm ) commands . }
  12.  
  13. { All other rights are reserved . }
  14.  
  15. {  ================================================== }
  16.  
  17. interface
  18.  
  19. { The NSHP unit defines the interfaces nshell to callbacks.  See "nshp.p" }
  20.  
  21.     uses
  22.         NSHC;
  23.  
  24. { The routine "theCommand" is called by the nShell.lib to to the work of the command. }
  25.  
  26.     procedure theCommand (nshc_parms: t_nshc_parms; nshc_calls: t_nshc_calls);
  27.  
  28. {  ================================================== }
  29.  
  30. implementation
  31.  
  32. {  ================================================== }
  33.  
  34. { pascal 'main' for commands }
  35.  
  36.     procedure theCommand (nshc_parms: t_nshc_parms; nshc_calls: t_nshc_calls);
  37.         var
  38.             s: Str255;
  39.     begin
  40.  
  41.         nshc_parms^.action := nsh_idle;
  42.  
  43.         if nshc_parms^.version <> NSHC_VERSION then
  44.             begin
  45.                 s := 'This command is not of a compatible version.';
  46.                 NSH_putStr_err(nshc_calls, s);
  47.                 NSH_putchar_err(nshc_calls, RETURN_CHAR);
  48.                 nshc_parms^.result := NSHC_ERR_VERSION;
  49.             end
  50.         else
  51.             begin
  52.                 s := 'hello from Pascal';
  53.                 NSH_putStr(nshc_calls, s);
  54.                 NSH_putchar(nshc_calls, RETURN_CHAR);
  55.                 nshc_parms^.result := 0;
  56.             end;
  57.  
  58.     end;
  59.  
  60. end.